<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Position 
{
	var $ci;
	function __construct()
	{
		$this->ci = & get_instance();
	}
	function get_position()
	{
		if($this->ci->uri->total_segments() > 3)
		{
			$uri = implode('/',array_slice($this->ci->uri->segment_array(),0,3));
		}else{
			$uri = $this->ci->uri->uri_string();
		}

		foreach($this->ci->admin_config['nav'] as $key=>$value)
		{
			foreach($value as $_key=>$_value)
			{
				if($_key !== 0){
					foreach($_value as $val)
					{
						if($val[1] == $uri)
						{
							$data['position']=array($key,$_key,$val[0]);
						}
					}
				}
			}
		}
		$data['tips'] = $this->get_tips();
		return $this->ci->load->view('admin/include//position',$data,TRUE);
	}

	function get_tips()
	{
		$this->ci->load->config('ciccms/tips');
		$tips_config = $this->ci->config->item('tips');
		@$tips = $tips_config[$this->ci->uri->rsegment(1)][$this->ci->uri->rsegment(2)];
		return @$tips[array_rand($tips)];
	}
}